package com.lvy.hczn.front.business.controller;

import com.lvy.hczn.front.system.domain.business.SpuGrade;
import com.lvy.hczn.front.business.service.SpuGradeService;
import com.lvy.hczn.front.business.util.ResultUtil;
import com.lvy.hczn.front.common.exception.UtilException;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/wcs/grade/")
@RestController
@Slf4j
public class SpuGradeController {

    @Autowired
    private SpuGradeService spuGradeService;

    @ApiOperation(value = "列表查询", notes = "列表查询")
    @PostMapping("selectList")
    public ResultUtil selectList(@RequestBody SpuGrade spuGrade) {
        try {
            return ResultUtil.ok(spuGradeService.selectList(spuGrade));
        } catch (Exception e) {
            log.error("selectList:{}", e);
            if (e instanceof UtilException) {
                return ResultUtil.failed(e.getMessage());
            } else {
                return ResultUtil.failed("系统异常");
            }
        }
    }
}
